#当用户登录时跳转到用户选择界面
import order_list as ol
import tkinter as tk
import psycopg2
from PIL import ImageTk, Image 
from link import *
from tkinter import messagebox
from parameter import *
from visitorselect import visitorSelect

class visitorPage():
    def __init__(self, master=None, name=None):
        self.name = name
        self.window = master
        self.window.title('访客界面')
        self.window.geometry('960x540')
        self.create_page()

    def create_page(self):
        global image1
        self.page = tk.Frame(self.window, width=960, height=540)
        self.page.pack()
        img = Image.open('lika.png')
        image1 = ImageTk.PhotoImage(img)
        label_img = tk.Label(self.page, image=image1)
        label_img.pack()

        tk.Label(self.page, text='家电', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin').place(x=140, y=10, anchor='nw')
        tk.Label(self.page, text='数码', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin').place(x=430, y=10, anchor='nw')
        tk.Label(self.page, text='鞋服', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin').place(x=720, y=10, anchor='nw')
        
        tk.Button(self.page, text='空调', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_air_conditioner)).place(x=140, y=70, anchor='nw')
        tk.Button(self.page, text='洗衣机', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_washing_machine)).place(x=140, y=200, anchor='nw')
        tk.Button(self.page, text='电视', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_television)).place(x=140, y=330, anchor='nw')
        tk.Button(self.page, text='热水器', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_heater)).place(x=140, y=460, anchor='nw')

        tk.Button(self.page, text='电脑', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_computer)).place(x=430, y=100, anchor='nw')
        tk.Button(self.page, text='手机', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_phone)).place(x=430, y=280, anchor='nw')
        tk.Button(self.page, text='相机', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_camera)).place(x=430, y=460, anchor='nw')

        tk.Button(self.page, text='鞋', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_shoes)).place(x=720, y=70, anchor='nw')
        tk.Button(self.page, text='卫衣', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_sweater)).place(x=720, y=200, anchor='nw')
        tk.Button(self.page, text='外套', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_loose_coat)).place(x=720, y=330, anchor='nw')
        tk.Button(self.page, text='裤子', font=('楷体', 25), bg='CornflowerBlue', fg='Moccasin', command=lambda:self.choose(my_trousers)).place(x=720, y=460, anchor='nw')

        tk.Button(self.page, text='已购商品', font=('楷体', 20), bg='LightCyan', fg='LightCoral', command=self.my_order_list).place(x=810, y=10, anchor='nw')

    def choose(self, mytype):
        self.page.destroy()
        visitorSelect(mytype, self.window, self.name)

    def my_order_list(self):
        self.page.destroy()
        ol.orderList(self.window, self.name)

        